﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace HotelCode.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PhotoController : ControllerBase
    {
        [HttpPost]
        public  IActionResult GetPhoto(IFormFile file)
        {
            string newfile=Directory.GetCurrentDirectory()+@"\wwwroot\imgs\"+file.FileName;
            using (FileStream fs=new FileStream(newfile,FileMode.Create))
            {
                file.CopyTo(fs);
                fs.Close();
            }
            return Ok("https://localhost:7185/imgs/" + file.FileName);
        }
    }
}
